% this code is for Jumps and Post-FOMC Announcement Returns in Currency Markets
% this gives table 4 (time series sorting)

clear
clc
load(using data including 12hr measures)

%% 1. time series sorting

exporttimesort=nan(nf,8);
addexporttimesort=nan(nf,3);
tp=0;
tprxe=hwrxe;
tprxe(:,19)=[];
tprxe(:,17)=[];
tprxe(:,12)=[];
tprxe(:,6)=[];
tprxe(:,2)=[];

for j=1:nhlf
    if hwindicator(j,9)>0   % indicator for effective 12 hr window obs.
        tp=tp+1;
        exporttimesort(tp,1)=nanmean(hwrxe(j+1,1:nc),2);
        exporttimesort(tp,2)=nanmean(tprxe(j+1,:),2);
        exporttimesort(tp,3)=hwrxe(j+1,nc+1);
        exporttimesort(tp,4)=nanmean(hwresirxe(j+1,1:nc),2);
        exporttimesort(tp,5)=hwsurp(j,1);   % monetary policy surprise
        exporttimesort(tp,6)=hwgvol(j,1);   % currency market volatility
        exporttimesort(tp,7)=hwfguiance(j,1); % forward guidance
        exporttimesort(tp,9)=hwswap(j,1);   % 10yr swap rate
        addexporttimesort(tp,1)=nanmean(sum(hwrxe(j-3:j-1,1:nc),1),2);
        addexporttimesort(tp,2)=nanmean(hwrxe(j-1,1:nc),2);
        addexporttimesort(tp,3)=nanmean(hwrxe(j,1:nc),2);  
    end    
end
clear j

% export (add)exportimesort to MS Excel with window numbering, then using
% Excel's Data/Filter, we sort 12 hr windows on each measure
% to get mean returns, we use AVERAGE function, and to compute standard
% deviation for standard errors, we use STDEV functions

